<template>
	<div class="login"  >
		<div class="login_box">
			 <button class="login_btn"  open-type="getPhoneNumber" @getphonenumber="bindLogin">手機號快捷登入/注册</button>

		</div>
		
	</div>
</template>

<script>
    export default {
		components: {
		    
		},
        data() {
            return {
				userName:'',
				loginType:false
            }
        },
		onShow: function() {
		
		},
        methods: {
			bindLogin(e) {
				console.log(e)
			
				this.login(e.detail.code)
			},
			login(code){
				let that=this
				let wxCode = uni.getStorageSync('wxCode')
				var para = {
					code:code,
				}
				console.log(para)
			
			},
		
			async wxlogin() {
				let that = this
				// 获取code
				var wxlogin = await wx.login()
				if (wxlogin.code) {
					var showModel = await uni.showModal({title: '温馨提示', content: '亲，授权获取用户信息才能正常使用小程序功能'})
					uni.setStorageSync('wxCode',wxlogin.code)
					if (showModel && showModel[1].confirm) {
						try {
							var result = await wx.getUserProfile({desc: '获取你的昵称、头像用于用户登录'})
							if (result && result.errMsg == 'getUserProfile:ok') {
								uni.setStorageSync('wxUserName',result.userInfo.nickName)
								this.loginType=true
							}
						}catch(e){}
						
										
					}
					
				} else {
					uni.hideLoading()
					console.log('登录失败！' + wxlogin.errMsg)
				}
			}
        },
        onReady() {
			
        }
    }
</script>

<style scoped>  
.userName{
	width: 80%;
	border-radius: 50rpx;
	margin: 100rpx auto 20rpx auto;
}
.login {
	width: 100%;
	height: 100%;
	min-height: 32rem;
	position: fixed;
}
.logo_img {
	width: 3.05rem;
	height: 3.1rem;
}
.name {
	font-size: 1.6rem;
	font-weight: bold;
	color: #E6000C;
	margin: 1rem 0 1.4rem;
}
.login_box {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding-top: 4rem;
}
.login_box input {
	box-sizing: border-box;
	padding: 0 1.4rem;
	width: 80%;
	height: 2.4rem;
	border: 1px solid #D7D9DE;
	border-radius: 25px;
	margin-bottom: 1.2rem;
}
.login_btn {
	width: 80%;
	height: 2.5rem;
	background: linear-gradient(-40deg,#f09a3c 0%,#f09a3c 100%);
	box-shadow: 0px 3px 8px #f09a3c;
	border-radius: 25px;
	text-align: center;
	line-height: 2.5rem;
	color: #FFFFFF;
	font-size: 0.8rem;
	letter-spacing: 2px;
	margin: 0.4rem 0 1.2rem;
}
.edit {
	display: flex;
	justify-content: center;
	align-items: center;
}
.edit span {
	margin: 0 0.8rem;
}
  .avatar{
	  width: 200rpx;
	  height: 200rpx;
	  overflow: hidden;
	  border-radius: 50%;
	  margin-bottom: 40rpx;
  }
</style>
